/*
 *   Copyright (c) 2010-2022, SIUFUNG
 */
package net.siufung.market.base.tenant.controller.assembler;

import com.google.common.collect.Lists;
import java.util.List;
import java.util.Objects;
import net.siufung.core.utils.CopyUtil;
import org.springframework.util.CollectionUtils;
import net.siufung.market.base.tenant.mapper.entity.TenantMenu;
import net.siufung.market.base.tenant.controller.model.vo.TenantMenuVo;

/**
 *
 * 系统菜单租户表 持久层展示层组装器
 *
 * @author 陈建峰
 * @since 2022-07-06 14:45:08
 */
public class TenantMenuAssembler {

    /**
     * TenantMenu 转换成 TenantMenuVo
     * @param tenantMenu 数据库实体
     * @return TenantMenuVo 视图
     */
    public static TenantMenuVo from(TenantMenu tenantMenu){
        if(!Objects.isNull(tenantMenu)){
            TenantMenuVo tenantMenuVo = new TenantMenuVo();
            CopyUtil.copyProperties(tenantMenu, tenantMenuVo);
            return tenantMenuVo;
        }
        return null;
    }

    /**
     * TenantMenuList 转换成 TenantMenuVoList
     * @param tenantMenuList 数据库实体集合
     * @return List<TenantMenuVo> 视图集合
     */
    public static List<TenantMenuVo> fromList(List<TenantMenu> tenantMenuList){
        List<TenantMenuVo> tenantMenuVoList = Lists.newArrayList();
        if(!CollectionUtils.isEmpty(tenantMenuList)){
            TenantMenuVo tenantMenuVo;
            for (TenantMenu tenantMenu: tenantMenuList) {
                tenantMenuVo = new TenantMenuVo();
                CopyUtil.copyProperties(tenantMenu, tenantMenuVo);
                tenantMenuVoList.add(tenantMenuVo);
            }
        }
        return tenantMenuVoList;
    }
}

